<?php
use doumiaoduo\layer\LayerConfirmWidget;
use doumiaoduo\layer\LayerIframeWidget;
use yii\helpers\Html;
use common\components\helpers\Fun;
LayerConfirmWidget::widget();
LayerIframeWidget::widget();
?>
<div class="yx-praise-list-box yx-praise-box yx-radius2 ">
    <!--/*添加按钮*/-->
    <?= $this->renderFile('@app/views/layouts/toolbar.php'); ?>
    <!--/*搜索*/-->
    <div id="search-area" class="yx-bgf7f7f7 yx-radius5 zx-mg yx-function2 yx-pr0">
        <?= Html::beginForm(Fun::url(['arrangement/index']), 'get', ['enctype' => 'multipart/form-data']) ?>
        <?= \common\components\helpers\Search::textInput('course_name', null, ['label'=>'课程名称','class' => 'search yx-width150 zx-lh24 yx-ml6']); ?>
        <?= \common\components\helpers\Search::textInput('teacher_name', null, ['label'=>'教师名称','class' => 'search  yx-width150 zx-lh24 yx-ml6']); ?>
        <?= \common\components\helpers\Search::textInput('mechanic_name', null, ['label'=>'机构','class' => 'search  yx-width150 zx-lh24 yx-ml6']); ?>
        <?=\common\components\helpers\Search::dropDownList('class_day',null,[null=>'请选择',1 => '星期一', 2 => '星期二', 3 => '星期三', 4 => '星期四', 5 => '星期五', 6 => '星期六', 7 => '星期日'],['label'=>'上课星期','promote'=>'请选择','class'=>'search diy_select_txt'])?>
        <?=\common\components\helpers\Search::dropDownList('class_day',null,[null=>'请选择',1 => '可预约', 2 => '不可预约'],['label'=>'是否可预订','promote'=>'请选择','class'=>'search diy_select_txt'])?>
        <?= \common\components\helpers\Search::submitButton('搜索', ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
        <?php Html::endForm() ?>
    </div>
    <!--/*表*/-->
    <div class="docs-main zx-mg">
        <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check" data-url="<?=\common\components\helpers\Fun::url(['arrangement/syncgoods'])?>"  data-tablesaw-mode="swipe" data-tablesaw-minimap >
            <thead>
            <tr class="yx-bgd2f6ec">
                <th><?=\Yii::t('zhtfrontend','ID');?></th>
                <th><?=\Yii::t('zhtfrontend','课程');?></th>
                <th><?=\Yii::t('zhtfrontend','老师');?></th>
                <th><?=\Yii::t('zhtfrontend','教室编号');?></th>
                <th><?=\Yii::t('zhtfrontend','教室名');?></th>
                <th><?=\Yii::t('zhtfrontend','课程时间');?></th>
                <th><?=\Yii::t('zhtfrontend','最满人数');?></th>
                <th><?=\Yii::t('zhtfrontend','开班人数');?></th>
                <th><?=\Yii::t('zhtfrontend','是否可预约');?></th>
                <th><?=\Yii::t('zhtfrontend','商品状态');?></th>
                <th><?=\Yii::t('zhtfrontend','创建时间');?></th>
                <th><?=\Yii::t('zhtfrontend','更新时间');?></th>
                <th style="width:55px;"><?=\Yii::t('zhtfrontend','类型');?></th>
                <th style="width:122px;"><?=\Yii::t('zhtfrontend','操作');?></th>
            </tr>
            </thead>
            <?php if($data):?>
                <?php foreach($data as $item):?>
                    <tr data-id="<?=$item['id']?>">
                        <td><?=$item['id']?></td>
                        <td><?=$item['course_name']?></td>
                        <td><?=$item['teacher_name']?></td>
                        <td><?=$item['room_number']?></td>
                        <td><?=$item['room_name']?></td>
                        <td><?=$item['class_time']?></td>
                        <td><?=$item['max_number']?></td>
                        <td><?=$item['opening_number']?></td>
                        <td><?=$item['booking']?></td>
                        <td><?=$item['creategoods']?></td>
                        <td><?=$item['created_at']?></td>
                        <td><?=$item['updated_at']?></td>
                        <td><?=$item['is_online']?></td>
                        <td><?=$item['operate']?></td>
                    </tr>
                <?php endforeach;?>
            <?php endif;?>
        </table>
        <div style="text-align: right"><?= common\components\widgets\GoPager::widget(['pagination' => $pages]) ?></div>
    </div>
</div>

<?php
$js = <<<JS
 layer.config({
        extend: ['skin/customskin/style.css']//加载您的扩展样式
    });
  $(document).on('click','.shelve',function(){
      var _this = $(this);
      var url = $('#tablesaw').data('url');
      var id = _this.data('id');
      _this.attr('disabled',true);
       $.ajax({
             url:url,
             type:'get',
             data:{id:id},
             dataType:'json',
             beforeSend:function(){
                layer.load(0, { shade: [0.5, '#393D49'] });
             },
             complete:function(){
              layer.close(layer.load(0, { shade: [0.5, '#393D49'] }));  
            },
            success:function(data){
                 if(data.status == 1){
                     layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                     _this.removeClass('shelve');
                     _this.css('color','#464656');
                     _this.html('最新商品');
                     return false;
                 }else{
                     layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                     _this.removeAttr("disabled");
                     return false;
                 }
        
            }
         });
      
      
      
      
  });
JS;
\Yii::$app->view->registerJs($js);
?>

